// 这是summary.vue, 表格合计行的组件，我仅增加了类名和方法

<template>
    <div style="overflow: hidden">
        <table class="ivu-table-summary" cellspacing="0" cellpadding="0" border="0" :style="styleObject">
            <colgroup>
                <col v-for="(column, index) in columns" :width="setCellWidth(column)" />
            </colgroup>
            <tbody :class="[prefixCls + '-tbody']">
                <tr class="ivu-table-row">
                    <td v-for="(column, index) in columns" :class="alignCls(column)">
                        <div class="ivu-table-cell" :class="cellCls(column)">
                            <span>{{ data[column.key].value }}</span>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>
<script>
import Mixin from 'view-design/src/components/table/mixin.js';

export default {
    name: 'TableSummary',
    mixins: [Mixin],
    props: {
        prefixCls: String,
        styleObject: Object,
        columns: Array,
        data: Object, // rebuildData
        columnsWidth: Object,
        fixed: {
            type: [Boolean, String],
            default: false
        }
    },
    methods: {
        cellCls(column) {
            return [
                {
                    ['ivu-table-hidden']:
                        (this.fixed === 'left' && column.fixed !== 'left') ||
                        (this.fixed === 'right' && column.fixed !== 'right') ||
                        (!this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right'))
                }
            ];
        }
    }
};
</script>
